package cn.funnyxb.tools.appFrame.database;

import android.content.Context;
import cn.funnyxb.tools.appFrame.debugTool.Debuger;

public final class DBHolder
{
  private Context context = null;
  private String dbName = null;
  protected DBService dbService = null;
  private int dbVersion = -1;
  private OnDBCreateListener onDBCreateListener = null;

  public DBHolder(Context paramContext, String paramString, int paramInt, OnDBCreateListener paramOnDBCreateListener)
    throws Exception
  {
    log("Constructor");
    this.context = paramContext;
    this.dbName = paramString;
    this.dbVersion = paramInt;
    this.onDBCreateListener = paramOnDBCreateListener;
    _checkDBInfo();
    this.dbService = new DBService(paramContext, paramString, null, paramInt, paramOnDBCreateListener);
  }

  private void _checkDBInfo()
    throws Exception
  {
    log("_checkDBInfo start");
    if (this.context == null)
      throw new Exception("db's context is null");
    if ((this.dbName == null) || (this.dbName.trim().length() == 0))
      throw new Exception("db's dbName is null");
    if (this.dbVersion < 0)
      throw new Exception("db's Version is invalid");
    log("_checkDBInfo end");
  }

  private void log(String paramString)
  {
    Debuger.log("dbholer", paramString);
  }

  public void closeDB()
  {
    try
    {
      if (this.dbService != null)
        this.dbService.close();
      this.dbService = null;
      return;
    }
    catch (Exception localException)
    {
      log("exception in closeDB");
    }
  }

  public Context getContext()
  {
    return this.context;
  }

  public DBService getDbService()
  {
    return this.dbService;
  }

  public int getDbVersion()
  {
    return this.dbVersion;
  }

  public OnDBCreateListener getOnDBCreateListener()
  {
    return this.onDBCreateListener;
  }

  public boolean isHolding()
  {
    if (this.dbService == null);
    for (int i = 0; ; i = 1)
      return i;
  }

  public boolean isPrepareDB()
    throws Exception
  {
    _checkDBInfo();
    if (this.dbService == null)
      this.dbService = new DBService(this.context, this.dbName, null, this.dbVersion, this.onDBCreateListener);
    return true;
  }
}

/* Location:           E:\Desktop\复件 classes_dex2jar.jar
 * Qualified Name:     cn.funnyxb.tools.appFrame.database.DBHolder
 * JD-Core Version:    0.5.3
 */